﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Shapes;
using System.Windows.Media;
using System.Windows.Media.Media3D;
using System.Windows.Media.Animation;
using Bling.DSL;
using Bling.Properties;
using Bling.Animation;
using Bling.WPF;
using Bling.Shapes;
using Bling.Slides;
using Bling.Util;
using Bling.Linq;
using Bling.Lighting;
using Bling.Physics;

namespace Presentation {
  public class CenterCanvas : Canvas {
    private PointBl Size0 = new PointBl(0, 0);
    public void Add(FrameworkElementBl elem) {
      CanvasBl canvas = this;
      elem.CanvasParent = canvas;
      elem.CenterTop = new PointBl(canvas.CenterSize.X, Size0.Y);
      Size0 = new PointBl(Size0.X.Max(elem.Width), elem.Bottom);
    }
    public void Init() {
      this.Bl().Size = Size0;
    }
  }


  public class Driver : SlideHolder {
    public Driver() {
      this["Title"] = () => new Title();
      this["Mismatch"] = () => new Mismatch();
      this["SolA"] = () => new SolutionA();
      this["SolB"] = () => new SolutionB();
      this["SolC"] = () => new SolutionC();
      this["Shaders"] = () => new ExampleC();
      this["Brand"] = () => new Branding();
      this["Layout"] = () => new LayoutSlide();
      this["CodeA"] = () => new CodeA();
      this["GenShader"] = () => new BezierTest();
      Init();
    }
    [STAThread]
    public static void Main(string[] args) {
      var win = new Window() { Title = "Bling Presentation", Content = new Driver() };
      new Application().Run(win);
      return;
    }
  }
  public class Title : AnimatedCanvas {
    public Title() {
      CanvasBl MainCanvas = this.Bl();
      MainCanvas.Background = Brushes.DarkBlue;
      CanvasBl TitleCanvas = new CanvasBl(MainCanvas) {
        CenterPosition = MainCanvas.CenterSize,
      };
      DoubleBl width = 0d;
      DoubleBl height = 0d;
      Action<LabelBl> Add = (label) => {
        label.CenterTop = new PointBl(TitleCanvas.CenterSize.X, height);
        label.Padding = 0d;
        width = width.Max(label.Width);
        height = label.Bottom;
      };
      Add(new LabelBl(TitleCanvas) {
        Font = { Size = 10, Weight = FontWeights.SemiBold, },
        Content = "Adding Bling to UIs".Bl(),
        Foreground = Brushes.Yellow,
      });
      Add(new LabelBl(TitleCanvas) {
        Font = { Size = 10, Weight = FontWeights.SemiBold, },
        Content = "with Lightweight DSLs".Bl(),
        Foreground = Brushes.Yellow,
      });
      Add(new LabelBl(TitleCanvas) {
        Font = { Size = 5, Weight = FontWeights.SemiBold, },
        Content = "Sean McDirmid".Bl(),
        Foreground = Brushes.White,
      });
      Add(new LabelBl(TitleCanvas) {
        Font = { Size = 5, Weight = FontWeights.SemiBold, },
        Content = "Microsoft ATC, Beijing China".Bl(),
        Foreground = Brushes.White,
      });
      TitleCanvas.Size = new PointBl(width, height);
      TitleCanvas.ScaleTo = MainCanvas.Size - new PointBl(10,10);
      return;
    }
  }

}
